package crazy.memory;

public class ClosureTest
{
	public static void main(String[] args)
	{
		final String str = "Java";
		new Thread(new Runnable()//内部类会扩大局部变量作用域
								 //所有被内部类访问的局部变量，必须使用final修饰
		{
			
			@Override
			public void run()
			{
				for (int i = 0; i < 100; i++)
				{
					System.out.println(str + " " + i);
					try
					{
						Thread.sleep(1000);
					}
					catch (Exception e)
					{
						// TODO: handle exception
					}
				}
				
			}
		}).start();
	}
}
